# Boost Chrono Library test Jamfile

# Copyright Beman Dawes 2008
# Copyright Vicente J. Botet Escriba 2009-2010

# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt

# See library home page at http://www.boost.org/libs/chrono

import testing ;
import os ;
import feature ;

project
    : requirements
        <target-os>freebsd:<linkflags>"-lrt"
        <target-os>linux:<linkflags>"-lrt -lpthread"
        <toolset>clang/<target-os>linux:<linkflags>"-lpthread"
        <toolset>pgi:<linkflags>"-lrt"
        #<threading>single:<define>BOOST_CHRONO_THREAD_DISABLED
        <toolset>msvc:<asynch-exceptions>on
        <define>BOOST_CHRONO_USES_MPL_ASSERT
        #<toolset>sun:<define>BOOST_COMMON_TYPE_DONT_USE_TYPEOF
        #<toolset>sun:<define>BOOST_TYPEOF_EMULATION
        <toolset>sun:<define>__typeof__=__typeof__
        <warnings>all
        <toolset>gcc:<cxxflags>-Wextra
        #<toolset>gcc:<cxxflags>-pedantic
        <toolset>clang:<warnings>on
        <toolset>gcc:<cxxflags>-Wno-long-long
        <toolset>gcc:<cxxflags>-Wno-variadic-macros
        <toolset>darwin:<cxxflags>-Wextra
        <toolset>darwin:<cxxflags>-pedantic
        <toolset>darwin:<cxxflags>-Wno-long-long
        <toolset>darwin:<cxxflags>-Wno-variadic-macros
        #<toolset>pathscale:<cxxflags>-Wextra
        <toolset>pathscale:<cxxflags>-Wno-long-long
        <toolset>pathscale:<cxxflags>-pedantic
        <toolset>clang:<cxxflags>-Wextra
        <toolset>clang:<cxxflags>-pedantic
        <toolset>clang:<cxxflags>-Wno-long-long
        <toolset>clang:<cxxflags>-Wno-variadic-macros
        <toolset>gcc-4.5.0,<target-os>windows:<cxxflags>-Wno-missing-field-initializers 
        <toolset>gcc-4.5.0,<target-os>windows:<cxxflags>-fdiagnostics-show-option 
        <toolset>msvc:<cxxflags>/wd4127
        <toolset>msvc:<cxxflags>/wd4512
# Note: Some of the remarks from the Intel compiler are disabled
# remark #193: zero used for undefined preprocessing identifier "XXX"
# remark #304: access control not specified ("public" by default)
# remark #383: value copied to temporary, reference to temporary used
# remark #444: destructor for base class "XXX" (declared at line YYY") is not virtual
# remark #593: variable "XXX" was set but never used
# remark #981: operands are evaluated in unspecified order
# remark #1418: external function definition with no prior declaration
# remark #2415: variable "XXX" of static storage duration was declared but never referenced

        <toolset>intel:<cxxflags>-wd193,304,383,444
        <toolset>intel:<cxxflags>-wd593,981
        <toolset>intel:<cxxflags>-wd1418
        <toolset>intel:<cxxflags>-wd2415
    ;

rule chrono-run ( sources )
{
    return
    [ run $(sources) ../build//boost_chrono
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_d  ]
    #[ run $(sources) ../build//boost_chrono/<link>static
    #    : :
    #    :
    #    :   $(sources[1]:B)_s ]
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_h ]
    ;
}

rule chrono-runXXX ( sources )
{
    return
    [ run $(sources) ../build//boost_chrono
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_d  ]
    #[ run $(sources) ../build//boost_chrono/<link>static
    #    : :
    #    :
    #    :   $(sources[1]:B)_s ]
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_h ]
    ;
}


rule chrono-v1-v2-run ( sources )
{
    return
    [ run $(sources) ../build//boost_chrono
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_d  ]
    [ run $(sources) ../build//boost_chrono/<link>static
        : :
        :
        :   v1_$(sources[1]:B)_s ]
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_h ]
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
           #<define>BOOST_CHRONO_VERSION=1
        :   v1_$(sources[1]:B)_h ]
    ;
}

rule chrono-run2 ( sources : name )
{
    return
    [ run $(sources) ../build//boost_chrono
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        :   $(name)_d  ]
    #[ run $(sources) ../build//boost_chrono/<link>static
    #    : :
    #    :
    #    : $(name)_s ]
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        : $(name)_h ]
    ;
}

rule date-run ( sources + )
{
    return
    [ run $(sources) ../build//boost_chrono
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_d  ]
    ;
}

rule date-run-2 ( sources + : name )
{
    return
    [ run $(sources) ../build//boost_chrono
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        :   $(name)_d  ]
    ;
}


rule chrono-run-mt ( sources )
{
    return
    [ run $(sources) ../build//boost_chrono
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_d  ]
    #[ run $(sources) ../build//boost_chrono/<link>static
    #    : :
    #    :
    #    :  $(sources[1]:B)_s ]
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_h ]
    ;
}
rule chrono-run2-mt ( sources * : name )
{
    return
    [ run $(sources) ../build//boost_chrono
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        :   $(name)_d  ]
    #[ run $(sources) ../build//boost_chrono/<link>static
    #    : :
    #    :
    #    : $(name)_s ]
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        : $(name)_h ]
    ;
}

rule chrono-run-check ( sources )
{
    return
    [ run $(sources)
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_d  ]
    [ run $(sources)
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_s ]
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_h ]
    ;
}

rule chrono-run-check2 ( sources : name )
{
    return
    [ run $(sources)
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        :   $(name)_d  ]
    [ run $(sources)
        : :
        :
            <define>BOOST_CHRONO_VERSION=2
        : $(name)_s ]
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        : $(name)_h ]
    ;
}

rule chrono-run-header ( sources )
{
    return
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_h ]
    ;
}

rule chrono-v1-v2-run-header ( sources )
{
    return
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        :   $(sources[1]:B)_h ]
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
        :   v1_$(sources[1]:B)_h ]
    ;
}

rule chrono-run-header2 ( sources : name )
{
    return
    [ run $(sources)
        : :
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        : $(name)_h ]
    ;
}

rule chrono-compile ( sources )
{
    return
    [ compile $(sources)
        :
            <define>BOOST_CHRONO_VERSION=2
        : $(sources[1]:B)_l ]
    [ compile $(sources)
        :   <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        : $(sources[1]:B)_h ]
    ;
}

rule chrono-compile2 ( sources : name )
{
    return
    [ compile $(sources)
        :
            <define>BOOST_CHRONO_VERSION=2
        : $(name)_l ]
    [ compile $(sources)
        :  <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_ERROR_CODE_HEADER_ONLY
           #<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
            <define>BOOST_CHRONO_VERSION=2
        : $(name)_h ]
    ;
}


    test-suite "examples"
        :
        [ chrono-run-header ../example/cycle_count.cpp  ]
        [ chrono-run-header ../example/runtime_resolution.cpp  ]
        [ chrono-run-header ../example/xtime.cpp ]
        [ chrono-run-header ../example/saturating.cpp  ]
        [ chrono-run ../example/min_time_point.cpp  ]
        [ chrono-run-header ../example/i_dont_like_the_default_duration_behavior.cpp ]
        [ chrono-run ../example/simulated_thread_interface_demo.cpp ]
        [ chrono-run-header ../example/timeval_demo.cpp ]
        [ chrono-run ../example/chrono_unit_test.cpp  ]
        [ chrono-run-header ../example/explore_limits.cpp  ]
        [ chrono-run-header ../example/test_duration.cpp ]
        [ chrono-run ../example/test_clock.cpp ]
        [ chrono-run-header ../example/miscellaneous.cpp ]
        [ chrono-run-header ../example/test_special_values.cpp ]
        [ chrono-run ../example/manipulate_clock_object.cpp ]
        [ chrono-run-mt ../example/test_thread_clock.cpp  ]
        [ chrono-run-header ../example/rounding.cpp  ]
        #[ chrono-run ../example/await_keystroke.cpp  ]
        ;

    test-suite "traits"
        :
        [ chrono-compile2 traits/common_type_duration_pass.cpp : traits_common_type_duration_p ]
        [ chrono-compile2 traits/common_type_time_point_pass.cpp : traits_common_type_time_point_p ]
        [ chrono-compile2 traits/treat_as_floating_point_pass.cpp : traits_treat_as_floating_point_p  ]
        [ chrono-run-header2 traits/duration_values_pass.cpp : traits_duration_values_p ]
        ;

    test-suite "duration"
        :
        [ compile-fail duration/duration_duration_fail.cpp  ]
        [ compile-fail duration/ratio_fail.cpp  ]
        [ compile-fail duration/positive_num_fail.cpp  ]
        [ chrono-compile duration/default_ratio_pass.cpp ]
        [ chrono-compile duration/types_pass.cpp ]
        [ chrono-compile duration/ratio_alias_pass.cpp ]
        [ chrono-compile duration/typedefs_pass.cpp  ]
        [ chrono-run-header duration/arithmetic_pass.cpp  ]
        [ chrono-run-header duration/duration_cast_pass.cpp  ]
        [ compile-fail duration/duration_cast_int_fail.cpp  ]
        [ chrono-run-header duration/comparisons_pass.cpp  ]
        [ chrono-run-header duration/constructor_pass.cpp  ]
        [ compile-fail duration/cons/convert_float_to_int_fail.cpp  ]
        [ compile-fail duration/cons/convert_inexact_fail.cpp  ]
        [ compile-fail duration/cons/implicit_constructot_fail.cpp  ]
        [ compile-fail duration/cons/non_implicit_convertible_rep_fail.cpp ]
        [ compile-fail duration/cons/treat_as_floating_point_Rep2_true_fail.cpp  ]
        [ compile-fail duration/nonmember/divide_rep2_fail.cpp  ]
        [ compile-fail duration/nonmember/modulus_rep2_fail.cpp  ]
        [ compile-fail duration/nonmember/times_rep2_lhs_fail.cpp ]
        [ compile-fail duration/nonmember/times_rep2_rhs_fail.cpp ]
        [ chrono-run-header duration/duration_values_pass.cpp ]
        [ chrono-run-header duration/rounding_pass.cpp  ]
        ;

    test-suite "time_point"
        :
        [ chrono-compile2 time_point/default_duration_pass.cpp : time_point_default_duration_p ]
        [ compile-fail time_point/not_duration_fail.cpp : : time_point_not_duration_f   ]
        [ chrono-run-header2 time_point/arithmetic_pass.cpp  : time_point_arithmetic_p ]
        [ chrono-run-header2 time_point/arithmetic_ext_pass.cpp  : time_point_arithmetic_ext_p ]
        [ chrono-run-header2 time_point/time_point_cast_pass.cpp  : time_point_time_point_cast_p ]
        [ compile-fail time_point/time_point_cast_int_fail.cpp : : time_point_time_point_cast_int_f   ]
        [ chrono-run-header2 time_point/comparisons_pass.cpp  : time_point_comparisons_p ]
        [ compile-fail time_point/comparisons/equal_fail.cpp : : time_point_equal_f   ]
        [ compile-fail time_point/comparisons/less_fail.cpp : : time_point_less_f   ]
        [ chrono-run-header2 time_point/constructor_pass.cpp  : time_point_constructor_p ]
        [ compile-fail time_point/cons/implicit_fail.cpp : : time_point_implicit_f   ]
        [ compile-fail time_point/cons/non_implicit_convertible_duration_fail.cpp : : time_point_non_implicit_convertible_duration_f   ]
        [ chrono-run-header2 time_point/min_max_pass.cpp  : time_point_min_max_p ]
        ;

    test-suite "clock"
        :
        [ chrono-run2-mt clock/clock_pass.cpp  : clock_clock_p ]
        [ chrono-run2-mt one_obj.cpp another_obj.cpp   : two_obj_p ]
        ;

    test-suite "io_ex"
        :
        [ chrono-v1-v2-run ../example/io_ex1.cpp  ]
        [ chrono-v1-v2-run-header ../example/io_ex2.cpp  ]
        [ chrono-v1-v2-run ../example/io_ex3.cpp  ]
        [ chrono-v1-v2-run ../example/io_ex4.cpp  ]
        [ chrono-v1-v2-run ../example/io_ex5.cpp  ]
        [ chrono-v1-v2-run ../example/french.cpp  ]
        ;

    test-suite "io"
        :
        [ chrono-v1-v2-run-header io/duration_input.cpp  ]
        [ chrono-v1-v2-run-header io/duration_output.cpp  ]
        [ chrono-v1-v2-run-header io/time_point_input.cpp  ]
        [ chrono-v1-v2-run-header io/time_point_output.cpp  ]
        [ chrono-run test_7868.cpp  ]
        [ chrono-run test_11006.cpp  ]
        [ chrono-run test_11012.cpp  ]
        [ chrono-runXXX test_12176.cpp  ]
        ;

    test-suite "win32"
        :
        [ chrono-run win32_test.cpp  ]
        ;

    explicit ts_ ;
    test-suite ts_
        :
        #[ chrono-run test_7868.cpp  ]
        #[ chrono-run test_9337.cpp  ]
        #[ chrono-run test_10778.cpp  ]
        [ chrono-run test_10631.cpp  ]
        ;

